package pCloud;

import java.sql.*;

public class DatabaseConnector {
	
	
	public static void main(String[] args) throws SQLException{
		//String driver = "org.postgresql.Driver";
		String database = "jdbc:postgresql:postgres";
		Connection con = DriverManager.getConnection(database,"postgres","TuanAnh1984") ;
		
		Statement stmt = con.createStatement();
		
		ResultSet rs = stmt.executeQuery("SELECT * FROM weather where timestamp > 0") ;
		
		int columnCount = rs.getMetaData().getColumnCount();
		
		for (int i=0; i<columnCount; i++){
			System.out.print(rs.getMetaData().getColumnName(i+1)+"\t");
		}
		System.out.println();
		
		while (rs.next()){
			for (int i=1; i<=columnCount; i++){
				System.out.print(rs.getObject(i)+"\t");
			}
			System.out.println();
		}
	}
}
